Subject: Beginner Question : Filling Arrays from Text Files
Message-ID: <1f7cc$13361c.91@news.hampshire.edu>
Date: Tue, 16 Jan 1996 00:54:28 GMT
Hi, we're writing a cgi program in c to produce a multiple-choice quiz on a web page. The program currently works, but we need to convert the contents of the question and answer arrays from being defined within the code:
to being filled by an external text file with an indeterminate (and changable) number of entries. We are trying to figure out how to use fread() to do this, but are totally confused as to how. We need to know : a)the required format of the text file to make the entire file readable into the array b) how to get the array "question" to fill itself with as many pointers/strings as are in the text file and c)use the number of entries in the text file to constrain rand().
Also, how does sizeof() work with fread, and do we need to use it?